using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ChellShow : Singleton_Base
{
    public GameObject showChell;
    public float showHeight;

    void Start(){
        showChell.SetActive(false);
    }

    void OnEnable(){
        EventHandler_Prop.ShowChellEvent += OnShowChellEvent;
    }

    void OnDisable(){
        EventHandler_Prop.ShowChellEvent -= OnShowChellEvent;
    }

    public void OnShowChellEvent(Vector3 showPosition){
        Vector3 targetPosition = new Vector3(showPosition.x, showPosition.y + showHeight, showPosition.z);
        showChell.transform.position = showPosition;
        showChell.SetActive(true);
    
        IEPool_Manager.instance.KeepTrueToDo("", ()=>{
            if((showChell.transform.position - targetPosition).magnitude > 0.1f){
                showChell.transform.position += (targetPosition - showChell.transform.position).normalized * Time.deltaTime;
                return true;
            }else{
                showChell.SetActive(false);
                return false;
            }
            
        });
    }

}
